#include "statusbar.h"

StatusBar::StatusBar()
{
    _layout = new QGridLayout;
    _layout->setContentsMargins(10, 0, 0, 0);
    _layout->setColumnStretch(0, 0);
    _layout->setColumnStretch(1, 1);
    _layout->setColumnStretch(2, 0);
    _layout->setColumnStretch(3, 1);
    _layout->setColumnStretch(4, 0);
    _layout->setColumnStretch(5, 1);
    _layout->setColumnStretch(6, 0);
    _layout->setColumnStretch(7, 1);
	_layout->setColumnStretch(8, 0);
	_layout->setColumnStretch(9, 1);
	_layout->setColumnStretch(10, 0);
	_layout->setColumnStretch(11, 1);
	_layout->setColumnStretch(12, 0);
	_layout->setColumnStretch(13, 1);

    _vertLabel = new QLabel("Vertex : ");
	_vertTotLabel = new QLabel("Total Vertices : ");
    _faceLabel = new QLabel("Face : ");
	_faceTotLabel = new QLabel("Total Faces: ");
    _edgeLabel = new QLabel("Edge : ");
	_edgeTotLabel = new QLabel("Total Edges: ");

    _timeLabel = new QLabel("Time(ms) : ");
    
	_v = new QLabel("");
    _f = new QLabel("");
    _e = new QLabel("");
	_vt = new QLabel("");
    _ft = new QLabel("");
    _et = new QLabel("");
    _t = new QLabel("");

    _layout->addWidget(_v, 0, 1);
    _layout->addWidget(_vt, 0, 3);
    _layout->addWidget(_f, 0, 5);
    _layout->addWidget(_ft, 0, 7);
    _layout->addWidget(_e, 0, 9);
    _layout->addWidget(_et, 0, 11);
    _layout->addWidget(_t, 0, 13);
    _layout->addWidget(_vertLabel, 0, 0);
	_layout->addWidget(_vertTotLabel, 0, 2);
    _layout->addWidget(_faceLabel, 0, 4);
	_layout->addWidget(_faceTotLabel, 0, 6);
    _layout->addWidget(_edgeLabel, 0, 8);
	_layout->addWidget(_edgeTotLabel, 0, 10);
    _layout->addWidget(_timeLabel, 0, 12);

    this->setLayout(_layout);

	_vert_total = 0;
	_edge_total = 0;
	_face_total = 0;

    refreshInfo();
}

void StatusBar::refreshInfo()
{
    if(_load)
    {
        int v = _vert;
        int f = _face;
        int e = _edge;
        int t = _time;
		int vt = _vert_total;
		int ft = _face_total;
		int et = _edge_total;

        _v->setNum(v);
        _f->setNum(f);
        _e->setNum(e);
		_vt->setNum(vt);
		_ft->setNum(ft);
		_et->setNum(et);
        _t->setNum(t);
    }
    else
    {
        _v->setText("");
        _f->setText("");
        _e->setText("");
		_vt->setText("");
        _ft->setText("");
        _et->setText("");
        _t->setText("");
    }

    _v->update();
    _f->update();
    _e->update();
    _vt->update();
    _ft->update();
    _et->update();
    _t->update();
}
